package com.itlaoqi.thread.juc;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;

public class CopyCnWriteArrayListSample {
    public static void main(String[] args) {
//        List<Integer> list = new ArrayList<>();
        List<Integer> list = new CopyOnWriteArrayList<Integer>();
        for (int i = 0; i < 1000; i++) {
            list.add(i);
        }
        Iterator<Integer> itr = list.iterator();
        while(itr.hasNext()){
            Integer i = itr.next();
            list.remove(i);
        }
        System.out.println(list);
    }
}
